package com.eample.pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static org.openqa.selenium.support.ui.ExpectedConditions.*;

public class InternalPage extends AnyPage {

	@FindBy(linkText = "Log out")
	public WebElement menuLogoutLink;

	@FindBy(linkText = "My profile")
	public WebElement menuProfileLink;

	@FindBy(linkText = "User management")
	public WebElement menuUserManagement;

	public boolean isOnThisPage() {
		return menuLogoutLink.isDisplayed();
	}

	public void logout() {
		// logout
		menuLogoutLink.click();
		wait_().until(alertIsPresent()).accept();

	}

	@Override
	void tryToOpen() {
		MyPageFactory.getPage(driver, LoginPage.class)
				.LoginWithValidCredentials("admin", "admin");

	}

	public UserPage GotoUserManagement() {
		menuUserManagement.click();
		return MyPageFactory.getPage(driver, com.eample.pages.UserPage.class);
	}

}
